package com.lzs.collection.method;

import java.util.ArrayList;
import java.util.List;

public class CollectionMethod {
    @SuppressWarnings("all")
    public static void main(String[] args) {
        List list = new ArrayList();
        //add添加单个元素
        list.add("jack");
        //集合只能存对象，底层会自动装箱
        list.add(10);
        list.add(new Integer(10));
        list.add(true);
        System.out.println("list="+list);
        //remove 删除指定元素
        list.remove("jack");
        list.remove(0);
        //contains:查找元素是否存在
        System.out.println(list.contains(10));
        //size：获取元素个数
        System.out.println(list.size());
        //isEmpty:判断是否为空
        System.out.println(list.isEmpty());
        //clear:清空
       // list.clear();
        System.out.println(list);
        //addAll:添加多个元素
        ArrayList arrayList = new ArrayList();
        arrayList.addAll(list);
        System.out.println(arrayList);
        //containsAll：查找多个元素是否存在
        System.out.println(arrayList.containsAll(list));
        //removeAll：删除多个元素
        arrayList.add(20);
        System.out.println(arrayList);
        boolean b = arrayList.removeAll(list);
        System.out.println(b);
    }
}
